package com.ykefu.assign.demo;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.nio.charset.Charset;
import java.util.List;

/**
 * @author likai
 * @date 2020/4/16 17:42
 * @email likai@7moor..com
 * @desc
 */
public class MessageWrapper extends ByteToMessageDecoder {

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        if(in.readableBytes()<4){
            return;
        }
        out.add(in.toString(Charset.forName("utf-8")));
        in.skipBytes(in.readableBytes());
    }
}
